function [smooth] = sg_filter(in, order)
% sg_filter implements Savitzy-Golay filter of order n
%
sg5 = [-3, 12, 17, 12, -3];
sg5d = 35;
sg7 = [-2 3 6 7 6 3 -2];
sg7d = 21;
sg9 = [-21 14 39 54 59 54 39 14 -21];
sg9d = 231;
switch (order)
case 5
	smooth = conv(sg5, in)/sg5d;   
   
case 7
   smooth = conv(sg5, in)/sg7d;
   
case 9
   smooth = conv(sg5, in)/sg9d;
   
otherwise
   smooth = in;
end
